<template>
  <div>
    <abouts ref="abouts" class="array" />
    <logins ref="logins" class="array" />
    <el-card>
      <div style="margin: 0 30px">
        <el-button type="warning" @click="InitializeMenu">初始化菜单</el-button>
        <el-button type="primary" @click="NewMenu">新增菜单</el-button>
      </div>
    </el-card>
    <el-table
      :data="homeInfo"
      style="margin: 0 50px"
      row-key="id"
      border
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="title" label="菜单名称" sortable width="230">
      </el-table-column>
      <el-table-column prop="" label="图标" sortable width="130">
        <template slot-scope="scope">
          <i :class="scope.row.icon"></i>
        </template>
      </el-table-column>
      <el-table-column prop="level" label="等级" sortable width="130">
      </el-table-column>
      <el-table-column prop="sort" label="排序" sortable width="130">
      </el-table-column>
      <el-table-column
        prop="permissionValue"
        label="权限标识"
        sortable
        width="230"
      >
      </el-table-column>
      <el-table-column prop="path" label="路由" sortable width="130">
      </el-table-column>
      <el-table-column prop="" label="组件路径" sortable width="130">
      </el-table-column>
      <el-table-column prop="status" label="是否可用" sortable width="130">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" sortable width="230">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import abouts from './components/abouts.vue'
import logins from './moutas/logins.vue'
import authority from '@/api/authority'
export default {
  components: {
    abouts,
    logins,
  },
  data() {
    return {
      homeInfo: [],
    }
  },
  created() {},
  mounted() {
    this.findAllPermissions()
    console.log('123')
  },
  methods: {
    findAllPermissions() {
      authority.findAllPermissionsApi().then(res => {
        console.log(res.data.menus)
        this.homeInfo = res.data.menus
        console.log(this.homeInfo, 'this.homeInfo.menus')
      })
    },
    //初始化菜单
    InitializeMenu() {
      console.log('初始化菜单')
      this.$refs.abouts.open()
    },
    //新增菜单
    NewMenu() {
      console.log('新增菜单')
      this.$refs.logins.open()
    },
  },
}
</script>

<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>